Skip to main content

FAQ & Troubleshooting

Common Questions

How do I add a new mock API endpoint?

Add an entry to node_modules/@cdx-extensions/di-sdk-web/dist/mocks/apiResponses.json with url, method, status, data, and optionally delay. It will be registered on the next widget start.

I want to call a real API locally. How?

Set isMock = false in node_modules/@cdx-extensions/di-sdk-web/dist/httpClient.js line 8, add your access_token on line 10, and set the real base URL in widgets/web/<widget>/src/environments/environment.ts. This is reset by npm install.

useUserContext() returns the same data every time locally.

It reads from node_modules/@cdx-extensions/di-sdk-web/dist/mocks/userContext.json. Edit that file to change the mock user's role, institution, email, etc.

My API call returns mock data locally but fails in production.

A cdx-extensions package version mismatch may cause this issue. Verify the required versions in the shared dependencies table.


Platform-Specific Questions

The widget works locally but is blank on the platform homepage.

Check: name in module-federation.config.ts matches what the host expects; exposes path points to a component with a valid default export; the build output is deployed to the correct static content location.


Pre-Submission Checklist

Confirm each of the following before submitting your widget to the platform team.

CheckHow to Verify
Renders without errorsRun nx serve <widget> and open in browser
User context displays correctlyVerify the user name/email from userContext.json appears as expected
API calls return mock dataTrigger any data-fetching action and confirm the response matches apiResponses.json
Branding renders correctlySwitch between branding-1 through branding-5 and verify colors/fonts update
TypeScript compiles cleanlyRun nx build <widget> and confirm zero errors
Module Federation config is correctVerify name and exposes in module-federation.config.ts match your component
Build output is correctRun nx build <widget> --configuration=production and verify dist/ contains remoteEntry.js

Testing with Real APIs

To verify your widget against a real backend during development:

  1. Set isMock = false in node_modules/@cdx-extensions/di-sdk-web/dist/httpClient.js (line 8).
  2. Provide a valid token in the access_token variable (line 10).
  3. Update your widget's environment file with the real API base URL (widgets/web/<widget>/src/environments/environment.ts).
  4. Start the widget with nx serve <widget> and exercise all API-dependent flows.
  5. Confirm that responses render correctly and error states are handled.
warning

Remember to revert httpClient.js changes before running npm install, or they will be overwritten.


Recommendations

DoDon't
Use sdk.getHttpClient() for all API callsUse raw fetch() or import Axios directly
Import SDK from @cdx-extensions/di-sdk onlyImport from @cdx-extensions/di-sdk-web in widget code
Use config.ts or environment files for API endpoint configurationHardcode API URLs directly in component code
Modify userContext.json to test different user scenarios locallyChange the structure of module-federation.config.ts or package.json
Add mock endpoints to apiResponses.json for local testingRemove existing entries from root package.json
Keep peerDependencies aligned with those in the shared dependencies tableChange React, MUI, or SDK versions independently
Copy the module-federation.config.ts pattern to your new widgetAssume the widget runs standalone — it always runs inside the OLB host
Set isMock = false in httpClient.js only for local real-call testingCommit node_modules/ changes
Contact the support team for domain whitelisting before deployingCall third-party APIs directly without whitelisting on the OLB